package com.hbnu.iostream;

import java.io.*;

/**
 * 需求：使用转换流读取指定文件中的内容，并输出到控制台中
 *
 * @author kittychen
 * @since 2025-10-11 下午 3:24
 */
public class InputStreamReaderDemo {
    public static void main(String[] args) {
        String path = "E:" + File.separator + "2310" + File.separator + "class2310.txt";
        File file = new File(path);

        InputStreamReader inputStreamReader = null;
        try {
            inputStreamReader = new InputStreamReader(new FileInputStream(file));
            char[] buffer = new char[1024];
            int len = inputStreamReader.read(buffer);
            System.out.println(new String(buffer, 0, len));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (inputStreamReader != null) {
                    inputStreamReader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
